<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Size
 *
 * @author sebastian
 */
class Common_View_Formatter_File_Size
{

    public static function getSize($size,$decimals=0)
    {
        //menor al KB
        if( $size < 1024 )
            return $size . " Bytes";
        //menor al MB
        if( $size < 1024*1024 )
            return number_format($size / 1024 , $decimals,",",".") . " KB";
        //menor al GB
        if( $size < 1024*1024*1024 )
            return number_format($size / 1024 / 1024  , $decimals,",",".") . " MB";
        //menor TR
        if( $size < 1024*1024*1024*1024 )
            return number_format($size / 1024 / 1024 /1024 , $decimals,",",".") . " GB";

        return $size;

    }

}
?>
